<!-- extend base layout -->
{% extends "base.html" %}
{% block content %}
<script type="text/javascript">

	$(function(){
		//框架左菜单
		$(".leftmenu").height($(window).height()-70);
		$("#conters").height($(window).height()-102);
		window.onresize=function(){
			$(".leftmenu").height($(window).height()-70);
			$("#conters").height($(window).height()-102);
		};
		$(".menuleft li ul li a").click(function(){
			$(this).parents("ul").children("a").removeClass("hover");
			$(".menuleft li ul li a").removeClass("hover");
			$(this).parents("ul").prev("a").addClass("hover");
			$(this).addClass("hover");
		});
		var flag=1;
    	$(".menuleft>li>a").live("click",function(){
			$(this).parents("li").siblings("li").children("ul").hide();
			$(this).parents("li").siblings("li").children("ul").children("a").removeClass("hover");
			$(this).parents("li").siblings("li").children("a").removeClass("hover");
			$(this).parents("li").siblings("li").children("a").children("i").html("&#xf067;");
			$(this).parents("li").children("a").children("i").html("&#xf068;");
			$(this).addClass("hover");
        if(flag==1){
           if ($(this).next("ul").is(':hidden')){ $(this).next("ul").slideDown();}
		   else{$(this).next("ul").slideUp();}
           flag=0;
        }else{
           if ($(this).next("ul").is(':hidden')){ $(this).next("ul").slideDown();}
		   else{$(this).next("ul").slideUp();}
           flag=1;
        }
		});
		//切换角色
		$(".user").click(function(){
			$(".showdivbg").show();
			$(".user_sub").css({"top":"-300px"}).show().animate({"top":0});
		});
		$(".close,.user_sub li").click(function(){
			$(".user_sub").animate({"top":-300},function(){
				$(".user_sub").hide();
			})
			$(".showdivbg").hide();
		});
	});

</script>
<title>微信运营支撑平台</title>
</head>
<body>
<header class="headertop">
	<div class="logoh1_top" style='cursor:pointer;' title="返回角色首页" id="logoNameId" url="" onclick="showRoleHomePage()">
    	<img src="{{ url_for('.static', filename='immanage_source/hd-logo.png')}}" width="100" height="50" alt=""/>
        <span class="logotit">微信运营支撑平台</span>
    </div>
    <ul class="rightnav">
    	<li class="userrole"><a href="#" id="showUser" title="角色：系统管理员">地域：角色<br/>欢迎您：</a></li>
    	<!--  <li class="user"><a href="javascript:;" title="岗位切换"><i class="icon-ico">&#xf007;</i>&nbsp;<i class="icon-ico">&#xf107;</i></a></li>-->
    	<li><a href="#" title="修改密码" onclick="updatePwd();"><i class="icon-ico">&#xf023;</i></a></li>
    	<li><a href="#" title="退出" onclick="logout()"><i class="icon-ico">&#xf011;</i></a></li>
    	<li><a href="#" title="帮助"><i class="icon-ico">&#xf059;</i></a></li>
    </ul>

</header>

<div class="leftmenu">
	<h4 class="titmenu" >我的权限菜单</h4>
    <ul id="menuId" class="menuleft"></ul>
</div>
<div class="rightcon">
	<div class="r_conter">
        <ul class="connav">
            <li><i class="icon-ico homeico">&#xf015; </i>&nbsp;</li>
            <li><a href="#">首页</a></li>
            <li><i class="icon-ico">&#xf101;</i></li>
            <li><a href="#" class="selected" id="menuShow"></a></li>
        </ul>
        <div class="conters">
        	<iframe frameborder="0" width="100%" scrolling="auto" src="" name="conters" id="conters"></iframe>
        </div>
    </div>
</div>

<link href="{{ url_for('.static', filename='immanage_source/3.2.1/assets/font-awesome/css/font-awesome.min.css') }}" rel="stylesheet" type="text/css" />

	<div class="showdivbg"></div>
    <ul class="user_sub">
    	<h3 class="tit"><span class="fl"><i class="icon-ico">&#xf007;</i>岗位切换</span><a href="javascript:;" class="fr close" ><i class="icon-ico">&#xf00d;</i></a></h3>
        <ol id="jobOl"></ol>
    </ul>

</body>
</html>
    <script type="text/javascript">
	/**
	 * 角色切换
	 */
	function changeJob(jobId){
    	jQuery.ajax({
			url:"login_Login_changeJob.action?jobId="+jobId,
			dataType:'json',
			success:function(data){
    			$(".close").click();
    			showMenu(data.ROLEID);
    			showUserSet(data);
				if(data.HOMEURL!=null&&data.HOMEURL!=""){
					$("#conters").attr("src","<%=basePath%>"+data.HOMEURL);
					$("#logoNameId").attr("url","<%=basePath%>"+data.HOMEURL);
				}else{
					$("#conters").attr("src","noHomePage.jsp");
					$("#logoNameId").attr("url","noHomePage.jsp");
				}
			},
			error:function(data,stat){
				//$(".close").click()
			}
		});
	}
	var ruleId="";
	/*
	 *设置 登录信息
	 */
	function showUserSet(data){
		var str = data.ROLENAME+":"+data.AREANAME+"</br>"+"欢迎您:"+data.STAFFNAME;

		$("#showUser").html(str);
		$("#showUser").attr("title","登录角色:"+data.ROLENAME+"|登录地域："+data.AREANAME+"|当前用户:"+data.STAFFNAME);
	}

	/**
	 * 设置当前菜单
	 */
	function setShowMenu(menuName){
		$("#menuShow").html(menuName);
	}

	/**
	 * 显示角色首页
	 */
	function showRoleHomePage(){
		$("#conters").attr("src",$("#logoNameId").attr("url"));
	}
	/**
	 * 显示菜单
	 */
	function showMenu(roleId){
    	jQuery.ajax({
			url:"common_Base_queryForList.action?sqlName=login.roleMenu&roleId="+roleId,
			dataType:'json',
			success:function(data){
				var menuStr="";
    			for(var i=0;i<data.length;i++){
					if(data[i].P_MENU_ID==null&&i!=0){
						menuStr += "</ul></li>";
					}
					if(data[i].P_MENU_ID==null){
				    	menuStr+="<li><a href='javascript:void(0)'  class='hover' target='conters'><span class='fl'>"+data[i].MENU_NAME
				    	        +"</span><i class='icon-ico fr'>&#xf067;</i></a>";
		    	        menuStr+="<ul>"
					}else{
						menuStr+= "<li><a href='<%=basePath%>page/"+data[i].MENU_URL+"' onclick=setShowMenu('"+data[i].MENU_NAME+"') target='conters'>"+data[i].MENU_NAME+"</a></li>";
					}
        		}
        		menuStr += "</ul></li>";
        		//alert(menuStr)
        		$("#menuId").html(menuStr);
        		//alert(menuStr)
			},
			error:function(data,stat){
				//$(".close").click()
			}
		});
	}



        $(function(){
        	jQuery.ajax({
				url:"common_Base_queryForList.action?sqlName=login.staffAuthority&staffId=${sessionScope.staffId}",
				dataType:'json',
				success:function(data){
					/**var jobHtml = "";
					for(var i=0;i<data.length;i++){
						jobHtml+="<li><a href='#' onclick=changeJob("+data[i].JOBID+")>"
						+"<strong>角色：</strong>"+data[i].ROLENAME
						+"&nbsp;&nbsp;&nbsp;&nbsp;<strong>地域：</strong>"+data[i].AREANAME
						+"</a></li>"
					}
					$("#jobOl").html(jobHtml);
					$(".user").click();
					**/
					showUserSet(data[0]);
					showMenu(data[0].ROLEID);
					ruleId=data[0].ROLEID;
				},
				error:function(data,stat){
				}
			});
        });

    	/**
    	 * 登出
    	 */
    	function logout(){
        	jQuery.ajax({
    			url:"login_Login_logout.action",
    			dataType:'json',
    			success:function(data){
        			location.href="login.jsp";
    			},
    			error:function(data,stat){
    				//$(".close").click()
    			}
    		});
    	}
    	var win;
    	  function  updatePwd(){
              win =$('<div id="win"></div>').window({
                title:'修改密码',
                width:350,
                height:250,
                onClose : function(){$(this).panel('destroy', null);},
                modal:true,
                cache : true,
                collapsible:false,
                minimizable:false,
                maximizable:false,
                href:'../sysmanage/staffPwdEdit.jsp'
            });
   }

    </script>
{% endblock %}